package com.tz.entity;

import java.util.List;

import javax.persistence.*;


@Entity
@Table(name="TBL_PRODUCT")
public class Product {

	private long id;

	private String name;

	private String subName;

	private double price;

	private double discount;

	private double tax;

	private String description;

	private List<Picture> pictures;

	private int stock;

	private String detail;

	private String color;

	private Category category;

	private String character;

	public Product() {
		
	}

	public Product(String name, String subName, double price, double discount,
			double tax, String description, List<Picture> pictures, int stock,
			String detail, String color, Category category, String character) {
		super();
		this.name = name;
		this.subName = subName;
		this.price = price;
		this.discount = discount;
		this.tax = tax;
		this.description = description;
		this.pictures = pictures;
		this.stock = stock;
		this.detail = detail;
		this.color = color;
		this.category = category;
		this.character = character;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="s1")
	@SequenceGenerator(name="s1",sequenceName="tbl_product_id")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Column(name="pr_name",nullable=false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="pr_subname",nullable=false)
	public String getSubName() {
		return subName;
	}

	public void setSubName(String subName) {
		this.subName = subName;
	}

	@Column(name="pr_price",nullable=false)
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	@Column(name="pr_discount",nullable=false)
	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	@Column(name="pr_tax",nullable=false)
	public double getTax() {
		return tax;
	}

	public void setTax(double tax) {
		this.tax = tax;
	}

	@Column(name="pr_description",nullable=false)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany
	@JoinColumn(name="product_id")
	public List<Picture> getPictures() {
		return pictures;
	}

	public void setPictures(List<Picture> pictures) {
		this.pictures = pictures;
	}

	@Column(name="pr_stock",nullable=false)
	public int getStock() {
		return stock;
	}

	public void setStock(int stock) {
		this.stock = stock;
	}

	@Column(name="pr_detail",nullable=false)
	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	@Column(name="pr_color",nullable=false)
	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	@OneToOne
	@JoinColumn(name="categoty_id")
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@Column(name="pr_character",nullable=false)
	public String getCharacter() {
		return character;
	}

	public void setCharacter(String character) {
		this.character = character;
	}

	@Override
	public String toString() {
		return "Product{" +
				"id=" + id +
				", name='" + name + '\'' +
				", price=" + price +
				", stock=" + stock +
/*					", subName='" + subName + '\'' +
			", discount=" + discount +
				", tax=" + tax +
				", description='" + description + '\'' +
				", pictures=" + pictures +
				", detail='" + detail + '\'' +
				", color='" + color + '\'' +
				", category=" + category +
				", character='" + character +*/ '\'' +
				"}\n";
	}
}
